/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ifpb.pod.registro;

import java.net.MalformedURLException;
import java.rmi.AccessException;
import java.rmi.Naming;
import java.rmi.NotBoundException;
import java.rmi.Remote;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;

/**
 *
 * @author Diogenes
 */
public class Registro {


    public static final int PORTA = 1099;
    public static final String IP = "localhost";

   
//    public static void createRegistro() throws RemoteException {
//        LocateRegistry.createRegistry(PORTA);
//    }
//
//    public static Registry getRegistro() throws RemoteException {
//        return LocateRegistry.getRegistry(IP, PORTA);
//    }

    public static Remote lookup(String nomeDeRegistro) throws RemoteException, NotBoundException, MalformedURLException {
        return Naming.lookup("rmi://" + IP + ":"+PORTA+"/"+nomeDeRegistro);
    }

    public static void rebind(String name, Remote obj) throws RemoteException, AccessException, MalformedURLException {
        Naming.rebind("rmi://" + IP + ":"+PORTA+"/"+name, obj);
    }
//    public static Remote lookup(String nomeDeRegistro) throws RemoteException, NotBoundException {
//        return getRegistro().lookup(nomeDeRegistro);
//    }
//
//    public static void rebind(String name, Remote obj) throws RemoteException, AccessException {
//        getRegistro().rebind(name, obj);
//    }
//
//     public void rebind(String name, Remote obj){
//
//     }
//
//    private Registry getRegistry(){
//
//    }
}
